package com.hengyue.quartz.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hengyue.common.core.entity.BaseEntity;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Transient;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;

import java.io.Serial;
import java.util.Date;
import java.util.Map;

/**
 * 定时任务调度日志表 sys_job_log
 * 
 * @author ruoyi
 */
@Setter
@Getter
@Entity
public class SysJobLog extends BaseEntity
{

    @Serial
    private static final long serialVersionUID = 1L;


    @GeneratedValue(generator = "SnowIdGenerator")
    @GenericGenerator(type = com.hengyue.common.utils.SnowIdGenerator.class, name = "SnowIdGenerator")
    @Id
    private Long id;


    /** ID */
    //@Excel(name = "日志序号")
    private Long jobLogId;

    /** 任务名称 */
    //@Excel(name = "任务名称")
    private String jobName;

    /** 任务组名 */
    //@Excel(name = "任务组名")
    private String jobGroup;

    /** 调用目标字符串 */
    //@Excel(name = "调用目标字符串")
    private String invokeTarget;

    /** 日志信息 */
    //@Excel(name = "日志信息")
    private String jobMessage;

    /** 执行状态（0正常 1失败） */
    //@Excel(name = "执行状态", readConverterExp = "0=正常,1=失败")
    private String status;

    /** 异常信息 */
    //@Excel(name = "异常信息")
    private String exceptionInfo;

    /** 开始时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date startTime;

    /** 停止时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date stopTime;

    /** 请求参数 */
    @Transient
    @JsonIgnore
    private Map<String, String> params;

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("jobLogId", getJobLogId())
            .append("jobName", getJobName())
            .append("jobGroup", getJobGroup())
            .append("jobMessage", getJobMessage())
            .append("status", getStatus())
            .append("exceptionInfo", getExceptionInfo())
            .append("startTime", getStartTime())
            .append("stopTime", getStopTime())
            .toString();
    }
}
